import axios from 'axios';

const service = axios.create({
    // process.env.NODE_ENV === 'development' 来判断是否开发环境
    // mock服务器地址
    // baseURL: 'https://api.it120.cc/lotus2495/mock',
    // baseURL: "http://admin-api.macrozheng.com",
    
    // baseURL: process.env.BASE_API, // api的base_url
    timeout: 5000 // 请求超时时间
});

// request拦截器
service.interceptors.request.use(
    config => {
        return config;
    },
    error => {
        console.log(error); // for debug
        return Promise.reject();
    }
);
// respone拦截器
service.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response.data;
        } else {
            Promise.reject();
        }
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);

export default service;
